//
//  NSDate+ZXExpand.m
//  ClassManager
//
//  Created by mac on 2017/12/28.
//  Copyright © 2017年 GZX. All rights reserved.
//

#import "NSDate+ZXExpand.h"

@implementation NSDate (ZXExpand)

+(NSString *)GetFormatWithInterval:(NSTimeInterval)interval WithFormat:(NSString *)format{
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    df.dateFormat = format;
    df.timeZone = [NSTimeZone systemTimeZone];
    return [df stringFromDate:date];
}
+(NSString*)GetWeekdayWithInterval:(NSTimeInterval)interval{
    NSArray *weekdays = [NSArray arrayWithObjects: [NSNull null], @"星期日", @"星期一", @"星期二", @"星期三", @"星期四", @"星期五", @"星期六", nil];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
    [calendar setTimeZone: timeZone];
    NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;
    NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:[NSDate dateWithTimeIntervalSince1970:interval]];
    return [weekdays objectAtIndex:theComponents.weekday];
}
@end
